<template>
  <div>
    <el-table :data="supplierSupplyOfGoodsList">
      <el-table-column prop="id" label="编号"></el-table-column>
      <el-table-column prop="user.uname" label="供应商名"></el-table-column>
      <el-table-column prop="shop.shopName" label="商品名"></el-table-column>
      <el-table-column prop="supplierPrice" label="供应商提供的价格"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" @click="audit(scope.row.id,1)">允许通过</el-button>
          <el-button size="mini" type="danger" @click="audit(scope.row.id,2)">拒绝通过</el-button>        </template>
      </el-table-column>
    </el-table>
    <div>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageno"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
    export default {
        name: "supply_of_goods_check",
        data(){
          return {
            supplierSupplyOfGoods:{
              isCheck:0,//审核状态为等待审核
              isDelete:0,//供应商品状态为正常供应商品
            },
            supplierSupplyOfGoodsList:[],
            pageno: 1,
            pagesize: 5,
            total: 1
          }
        },
        methods:{
          getData(){
            let params=new URLSearchParams();
            params.append("pageno", this.pageno);
            params.append("pagesize", this.pagesize);
            Object.keys(this.supplierSupplyOfGoods).forEach(item=>{
              params.append(item,this.supplierSupplyOfGoods[item]);
            })
            //调用异步，根据当前用户，查询供应商目前可以添加到供应商维护商品表的商品
            this.$axios.get("supplierSupplyOfGoods/supplierSupplyOfGoods.action",{params:this.supplierSupplyOfGoods}).
            then((response)=> {   //异步调用成功执行
              //将查询到的数据存入对象数组中
              this.supplierSupplyOfGoodsList=response.data.records;
              this.total = response.data.total;
              console.log(this.supplierSupplyOfGoodsList);
            }).catch(function (error) {//异步调用失败执行
              alert(error);
            });
          },
          audit(id,isCheck){
            let supplierSupplyOfGoods={
              id:id,
              isCheck:isCheck
            }
            //调用异步，进行审核
            this.$axios.post("supplierSupplyOfGoods/checkSupplierSupplyOfGoods.action",supplierSupplyOfGoods)
              .then(res=>{
                if(res.data.x){
                  this.$message.success(res.data.msg);
                }else {
                  this.$message.error(res.data.msg);
                }
                //重新查询一次数据
                this.getData();
              })
              .catch(err=>{
                this.$message.warning(err);
                alert(err);
              })
          },
          handleSizeChange(val) {
            //每页范围
            this.pagesize = val;
            this.getShopData();
          },
          handleCurrentChange(val) {
            //当前页
            this.pageno = val;
            this.getShopData();
          },
        },
        created() {
          this.getData();
        }
    }
</script>

<style scoped>

</style>
